// src/types/api.ts

// 3. 认证接口
export interface RegisterRequest {
  username: string;
  password: string;
  email?: string;
}

export interface LoginRequest {
  username: string;
  password: string;
}

export interface LoginResponse {
  token: string;
}

// 4. 家谱项目接口
export interface FamilyTree {
  familyId: number;
  userId: number;
  name: string;
  contentDesc?: string;
  createTime?: string;
  updateTime?: string; // 更新时间
  isDeleted?: boolean;
}

export interface CreateFamilyTreeRequest {
    name: string;
    contentDesc?: string;
}

// 5. 成员接口
export interface Person {
  personId: number;
  familyId: number;
  name: string;
  gender?: 'M' | 'F' | 'O';
  birthDate?: string;
  deathDate?: string;
  isDeleted?: boolean;
  familyName?: string;
}

export interface PersonFormData {
    personId?: number;
    familyId: number;
    name: string;
    gender: 'M' | 'F' | 'O';
    birthDate?: string;
    deathDate?: string;
}

// 7. 事件接口
export interface Event {
    eventId: number;
    personId: number;
    eventType: string;
    eventDate: string;
    description?: string;
    isDeleted?: boolean;
}

export interface EventFormData {
    eventId?: number;
    personId: number;
    eventType: string;
    eventDate: string;
    description?: string;
}

// 6. 关系接口
export interface RelationInfoDTO {
    relationId: number; // 【新增】关系的唯一ID，这是删除操作的关键
    relationName: string;
    relatedPerson: Person;
}


export interface AddRelationRequest {
    personId1: number;
    // 【修正】允许为 null 以便表单初始化
    personId2: number | null;
    relationTypeId: number | null;
}

// 成员完整详情 DTO (统一使用这一个)
export interface PersonDetailDTO {
    personInfo: Person;
    events: Event[];
    relations: RelationInfoDTO[];
}

// 8. 家谱查询接口 (ECharts 节点类型)
export interface GenealogyNodeDTO {
    person: Person;
    spouses: Person[];
    children: GenealogyNodeDTO[];
    name: string;
    personId: number;
    tooltip?: { formatter: string; };
}

// 通用字典类型
export interface CommonType {
    itemId: number;
    itemName: string;
}
